package sphere.view;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.KeyListener;



import sphere.controller.SphereControler;

public class SphereWindow extends Frame {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private static final String RADIUS="Rayon :";
	private static final String SURFACE="Surface :";
	private static final String VOLUME="Volume :";
	private final static String title="Application Sphere";

	//private Button valider;
	
	//private final SphereController controller;
	private TextField rayon, volume, surface;
	
	
	protected class PrivListener extends WindowAdapter {
	
		public void windowClosing (WindowEvent e){
			System.exit(0);
			}
	}
	
	public SphereWindow(){
		super(title);
		PrivListener monListener=new PrivListener();
		this.addWindowListener(monListener);
		
		
		setLayout(new GridLayout(0,2,10,10));
		add(new Label(RADIUS));
		add(rayon=new TextField(""));
		add(new Label(VOLUME));
		add(volume=new TextField(""));
		add(new Label(SURFACE));
		add(surface=new TextField(""));
		//add(new Button("Valider"));

		//SphereController= new ControleurDuDe ( this ) ;
		//keyPressed.a(SphereControler) ;
		volume.setEditable(false);
		surface.setEditable(false);
		
		SphereControler sc = new SphereControler(this);
		rayon.addTextListener(sc);
		this.pack();
		this.setVisible(true);
	}


	public String getRayon()
	{
		return this.rayon.getText();
	}


	public void setVolume(String volume)
	{
		this.volume.setText(volume);
	}


	public void setSurface(String surface)
	{
		this.surface.setText(surface);
	}
	

		

}
/**
 * http://docs.oracle.com/javase/7/docs/api/javax/swing/text/JTextComponent.html#getText()
 */


